package repository;

import java.sql.ResultSet;
import java.sql.SQLException;
import dbConnect.dbConnecter;
import Dto.UserTbEntity;

public class LoginRepositor {
    public LoginRepositor() {

    }

    public boolean login(String Account,String Pwd) throws SQLException {
        dbConnecter Con = new dbConnecter();
        Con.getConnection();
        String sql = "select count(*) from User_tb where userAccount=" + dbConnecter.toSql(Account) + " and userPwd="+dbConnecter.toSql(Pwd);
        try {
            ResultSet set = Con.querySql(sql);
            while(set.next()) {
                int Count = set.getInt(1);
                System.out.println("Count = "+ Count);
                if (Count == 1) {
                    return true;
                }
            }
            return false;
        }
        catch (Exception e)
        {
            e.printStackTrace();
            return false;
        }
        finally {
            Con.close();
        }
    }

}
